#include<iostream>
#include<cstdio>
using namespace std;
long long n,l,r;
int main()
{
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	cin>>n>>l>>r;
	int ans=0;
	if(r-l>=n)
	{
		cout<<n-1;
	}
	else
	{
		int x=l%n;
		int y=r%n;
		if(x>y)
		{
			cout<<n-1;
		}
		else
		{
			cout<<y;
		}
	}
	fclose(stdin);
	fclose(stdout);
	return 0;
}
